home *** CD-ROM | disk | FTP | other *** search
/ MacWorld Secrets (4th Edition) / Mac Secrets CD 4th Ed.toast / Apple Advanced Technologies / Apple Speech Technologies 1.5 / PlainTalk Developer Info / Speech Synthesis Manager SDK / Interfaces / Speech.h < prev    next >
Text File  |  1993-07-20  |  9KB  |  260 lines

  1. /************************************************************
  2.  
  3. Created: Friday, June 26, 1993 at 12:27 PM
  4.  Speech.h
  5.  C Interface to the Macintosh Libraries
  6.  
  7.  
  8.   Copyright Apple Computer, Inc. 1993
  9.   All rights reserved
  10.  
  11. ************************************************************/
  12.  
  13. #ifndef _SPEECH_
  14. #define _SPEECH_
  15.  
  16. #ifndef __TYPES__
  17. #include <Types.h>
  18. #endif
  19.  
  20. #ifndef __MEMORY__
  21. #include <Memory.h>
  22. #endif
  23.  
  24. #ifndef __FILES__
  25. #include <Files.h>
  26. #endif
  27.  
  28.  
  29.  
  30.  
  31. /*Speech Manager errors*/
  32. enum {
  33.  noSynthFound = -240,
  34.  synthOpenFailed = -241,
  35.  synthNotReady = -242,
  36.  bufTooSmall = -243,
  37.  voiceNotFound = -244,
  38.  incompatibleVoice = -245,
  39.  badDictFormat = -246,
  40.  badInputText = -247
  41. };
  42.  
  43.  
  44. #define gestaltSpeechAttr             'ttsc'    /* Gestalt Manager selector for Speech Attributes */
  45.  
  46. enum {
  47.     gestaltSpeechMgrPresent = 0                /* Gestalt bit which indicates that Speech Manager exists */
  48. };
  49.  
  50. #define kTextToSpeechSynthType         'ttsc'    /* Text-to-Speech Synthesizer component type     */
  51. #define kTextToSpeechVoiceType         'ttvd'    /* Text-to-Speech Voice resource type             */
  52. #define kTextToSpeechVoiceFileType     'ttvf'    /* Text-to-Speech Voice file type                 */
  53. #define kTextToSpeechVoiceBundleType 'ttvb'    /* Text-to-Speech Voice Bundle file type        */
  54.  
  55. enum {                                        /* constants for SpeakBuffer and TextDone callback controlFlags bits */
  56.     kNoEndingProsody     = 1,
  57.     kNoSpeechInterrupt     = 2,
  58.     kPreflightThenPause    = 4
  59. };
  60.  
  61. enum {                                        /* constants for StopSpeechAt and PauseSpeechAt */
  62.     kImmediate        = 0,
  63.     kEndOfWord        = 1,
  64.     kEndOfSentence    = 2
  65. };
  66.  
  67. #define soStatus                'stat'        /* GetSpeechInfo & SetSpeechInfo selectors */
  68. #define soErrors                'erro'
  69. #define soInputMode                'inpt'
  70. #define soCharacterMode            'char'
  71. #define soNumberMode            'nmbr'
  72. #define soRate                    'rate'
  73. #define soPitchBase                'pbas'
  74. #define soPitchMod                'pmod'
  75. #define soVolume                'volm'
  76. #define soSynthType                'vers'
  77. #define soRecentSync            'sync'
  78. #define soPhonemeSymbols        'phsy'
  79. #define soCurrentVoice            'cvox'
  80. #define soCommandDelimiter        'dlim'
  81. #define soReset                    'rset'
  82. #define soCurrentA5                'myA5'
  83. #define soRefCon                'refc'
  84. #define soTextDoneCallBack        'tdcb'
  85. #define soSpeechDoneCallBack    'sdcb'
  86. #define soSyncCallBack            'sycb'
  87. #define soErrorCallBack            'ercb'
  88. #define soPhonemeCallBack        'phcb'
  89. #define soWordCallBack            'wdcb'
  90. #define soSynthExtension        'xtnd'
  91.  
  92.  
  93.  
  94. /* Speaking Mode Constants */
  95.  
  96. #define modeText        'TEXT'        /* input mode constants                 */
  97. #define modeTX            'TX'
  98. #define modePhonemes    'PHON'
  99. #define modePH            'PH'
  100. #define modeNormal        'NORM'        /* character mode and number mode constants */
  101. #define modeLiteral        'LTRL'
  102.  
  103. enum {                                /* GetVoiceInfo selectors                 */
  104.     soVoiceDescription    = 'info',    /* gets basic voice info                 */
  105.     soVoiceFile            = 'fref'    /* gets voice file ref info             */
  106. };
  107.  
  108. typedef struct SpeechChannelRecord {
  109.     long data[1];
  110. } SpeechChannelRecord;
  111.  
  112. typedef SpeechChannelRecord *SpeechChannel;
  113.  
  114. typedef struct VoiceSpec {
  115.     OSType    creator;                /* creator id of required synthesizer     */
  116.     OSType    id;                        /* voice id on the specified synth         */
  117. } VoiceSpec;
  118.  
  119. enum {kNeuter = 0, kMale, kFemale};    /* returned in gender field below         */
  120.  
  121. typedef struct VoiceDescription {
  122.     long        length;                /* size of structure - set by application     */
  123.     VoiceSpec     voice;                /* voice creator and id info                 */
  124.     long        version;            /* version code for voice                     */
  125.     Str63        name;                /* name of voice                             */
  126.     Str255        comment;            /* additional text info about voice         */
  127.     short        gender;                /* neuter, male, or female                    */
  128.     short        age;                /* approximate age in years                 */
  129.     short        script;                /* script code of text voice can process     */
  130.     short        language;            /* language code of voice output speech     */
  131.     short         region;                /* region code of voice output speech         */
  132.     long        reserved[4];        /* always zero - reserved for future use    */
  133. } VoiceDescription;
  134.  
  135. typedef struct VoiceFileInfo {
  136.     FSSpec        fileSpec;            /* volume, dir, & name information for voice file */
  137.     short        resID;                /* resource id of voice in the file */
  138. } VoiceFileInfo;
  139.  
  140. typedef struct SpeechStatusInfo {
  141.     Boolean    outputBusy;             /* TRUE if audio is playing         */
  142.     Boolean    outputPaused;            /* TRUE if channel is paused         */
  143.     long    inputBytesLeft;         /* bytes left to process             */
  144.     short    phonemeCode;            /* opcode for cur phoneme             */
  145. } SpeechStatusInfo;
  146.  
  147. typedef struct SpeechErrorInfo {
  148.     short    count;                    /* # of errs since last check         */
  149.     OSErr    oldest;                    /* oldest unread error                 */
  150.     long    oldPos;                    /* char position of oldest err         */
  151.     OSErr    newest;                    /* most recent error                 */
  152.     long    newPos;                    /* char position of newest err         */
  153. } SpeechErrorInfo;
  154.  
  155. typedef struct SpeechVersionInfo {
  156.     OSType        synthType;            /* always ‘ttsc’                     */
  157.     OSType        synthSubType;        /* synth flavor                     */
  158.     OSType        synthManufacturer;    /* synth creator ID                 */
  159.     long        synthFlags;            /* synth feature flags                 */
  160.     NumVersion    synthVersion;         /* synth version number             */
  161. } SpeechVersionInfo;
  162.  
  163. typedef struct PhonemeInfo {
  164.     short    opcode;                    /* opcode for the phoneme             */
  165.     Str15    phStr;                    /* corresponding char string         */
  166.     Str31    exampleStr;                /* word that shows use of phoneme     */
  167.     short    hiliteStart;            /* segment of example word that         */
  168.     short    hiliteEnd;                /* should be hilighted (ala TextEdit) */
  169. } PhonemeInfo;
  170.  
  171. typedef struct PhonemeDescriptor {
  172.     short        phonemeCount;         /* # of elements         */
  173.     PhonemeInfo    thePhonemes[1];     /* element list         */
  174. } PhonemeDescriptor;
  175.  
  176. typedef struct SpeechXtndData {
  177.     OSType    synthCreator;            /* synth creator id     */
  178.     Byte    synthData[2];            /* data TBD by synth     */
  179. } SpeechXtndData;
  180.  
  181. typedef struct DelimiterInfo {
  182.     Byte    startDelimiter[2];        /* defaults to “[[“     */
  183.     Byte    endDelimiter[2];        /* defaults to “]]“     */
  184. } DelimiterInfo;
  185.  
  186. typedef pascal void (*SpeechTextDoneCBPtr)     (SpeechChannel, long, Ptr *, long *, long *);    /* Text-done callback routine typedef     */
  187. typedef pascal void (*SpeechDoneCBPtr)         (SpeechChannel, long );                            /* Speech-done callback routine typedef */
  188. typedef pascal void (*SpeechSyncCBPtr)         (SpeechChannel, long, OSType);                    /* Sync callback routine typedef         */
  189. typedef pascal void (*SpeechErrorCBPtr)     (SpeechChannel, long, OSErr, long);                /* Error callback routine typedef         */
  190. typedef pascal void (*SpeechPhonemeCBPtr)     (SpeechChannel, long, short);                    /* Phoneme callback routine typedef     */
  191. typedef pascal void (*SpeechWordCBPtr)         (SpeechChannel, long, long, short);                /* Word callback routine typedef         */
  192.  
  193. #ifdef __cplusplus
  194. extern "C" {
  195. #endif
  196.  
  197. pascal NumVersion SpeechManagerVersion (void)
  198.     = {0x203C,0x0000,0x000C,0xA800};
  199.  
  200. pascal OSErr MakeVoiceSpec (OSType creator, OSType id, VoiceSpec *voice)
  201.     = {0x203C,0x0604,0x000C,0xA800};
  202. pascal OSErr CountVoices (short *numVoices)
  203.     = {0x203C,0x0108,0x000C,0xA800};
  204. pascal OSErr GetIndVoice (short index, VoiceSpec *voice)
  205.     = {0x203C,0x030C,0x000C,0xA800};
  206. pascal OSErr GetVoiceDescription (VoiceSpec *voice, VoiceDescription *info, long infoLength)
  207.     = {0x203C,0x0610,0x000C,0xA800};
  208. pascal OSErr GetVoiceInfo (VoiceSpec *voice, OSType selector, void *voiceInfo)
  209.     = {0x203C,0x0614,0x000C,0xA800};
  210.  
  211. pascal OSErr NewSpeechChannel (VoiceSpec *voice, SpeechChannel *chan)
  212.     = {0x203C,0x0418,0x000C,0xA800};
  213. pascal OSErr DisposeSpeechChannel (SpeechChannel chan)
  214.     = {0x203C,0x021C,0x000C,0xA800};
  215.  
  216. pascal OSErr SpeakString (StringPtr s)
  217.     = {0x203C,0x0220,0x000C,0xA800};
  218. pascal OSErr SpeakText (SpeechChannel chan, Ptr textBuf, long textBytes)
  219.     = {0x203C,0x0624,0x000C,0xA800};
  220. pascal OSErr SpeakBuffer (SpeechChannel chan, Ptr textBuf, long textBytes, long controlFlags)
  221.     = {0x203C,0x0828,0x000C,0xA800};
  222.  
  223. pascal OSErr StopSpeech (SpeechChannel chan)
  224.     = {0x203C,0x022C,0x000C,0xA800};
  225. pascal OSErr StopSpeechAt (SpeechChannel chan, long whereToStop)
  226.     = {0x203C,0x0430,0x000C,0xA800};
  227. pascal OSErr PauseSpeechAt (SpeechChannel chan, long whereToPause)
  228.     = {0x203C,0x0434,0x000C,0xA800};
  229. pascal OSErr ContinueSpeech (SpeechChannel chan)
  230.     = {0x203C,0x0238,0x000C,0xA800};
  231.  
  232. pascal short SpeechBusy (void)
  233.     = {0x203C,0x003C,0x000C,0xA800};
  234. pascal short SpeechBusySystemWide (void)
  235.     = {0x203C,0x0040,0x000C,0xA800};
  236.  
  237. pascal OSErr SetSpeechRate (SpeechChannel chan, Fixed rate)
  238.     = {0x203C,0x0444,0x000C,0xA800};
  239. pascal OSErr GetSpeechRate (SpeechChannel chan, Fixed *rate)
  240.     = {0x203C,0x0448,0x000C,0xA800};
  241. pascal OSErr SetSpeechPitch (SpeechChannel chan, Fixed pitch)
  242.     = {0x203C,0x044C,0x000C,0xA800};
  243. pascal OSErr GetSpeechPitch (SpeechChannel chan, Fixed *pitch)
  244.     = {0x203C,0x0450,0x000C,0xA800};
  245. pascal OSErr SetSpeechInfo (SpeechChannel chan, OSType selector, void *speechInfo)
  246.     = {0x203C,0x0654,0x000C,0xA800};
  247. pascal OSErr GetSpeechInfo (SpeechChannel chan, OSType selector, void *speechInfo)
  248.     = {0x203C,0x0658,0x000C,0xA800};
  249.  
  250. pascal OSErr TextToPhonemes (SpeechChannel chan, Ptr textBuf, long textBytes, Handle phonemeBuf, long *phonemeBytes)
  251.     = {0x203C,0x0A5C,0x000C,0xA800};
  252.  
  253. pascal OSErr UseDictionary (SpeechChannel chan, Handle dictionary)
  254.     = {0x203C,0x0460,0x000C,0xA800};
  255.  
  256. #ifdef __cplusplus
  257. }
  258. #endif
  259. #endif
  260.